package zero.tech.games.dn.event;

import zero.tech.core.ZeroContext;
import zero.tech.core.data.SimpleUser;
import zero.tech.core.event.EventCallbackListener;
import zero.tech.core.event.EventType;
import zero.tech.games.common.ClubMemberUtil;
import zero.tech.games.dn.data.DnConfig;
import zero.tech.games.entity.games.Club;
import zero.tech.games.entity.games.ClubMember;
import zero.tech.games.logic.common.Room;
import zero.tech.games.logic.data.LogicEventType;

public class CheckJoinClubRoomMoney implements EventCallbackListener<Boolean>{

	@Override
	public EventType netEventType() {
		return LogicEventType.CHECK_JOIN_CLUB_ROOM_NEEDMONEY;
	}

	@Override
	public Boolean notifyEvent(Object... objs) {
		Room room = (Room) objs[0];
		SimpleUser simpleUser = (SimpleUser) objs[1];
		DnConfig dnConfig =(DnConfig) room.getGameConfig();
		Long admission_fee=dnConfig.getAdmission_fee();
		Club club=room.getClub();
		ClubMemberUtil clubMemberUtil=ZeroContext.getInstance(ClubMemberUtil.class);
		int uid=simpleUser.getUid();
		int club_id=club.getClub_id();
		ClubMember clubMember=clubMemberUtil.getClubMember(club_id,uid);
		long tea=clubMember.getTea();
		if(tea<admission_fee) {
			return false;
		}
		return true;
	}

	@Override
	public boolean asynchronous() {
		return false;
	}

}
